package com.greyu.ysj.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.greyu.ysj.config.ResultStatus;
import com.greyu.ysj.entity.CbtDraw;
import com.greyu.ysj.entity.CbtDrawExample;
import com.greyu.ysj.entity.InvTree;
import com.greyu.ysj.entity.InvTreeExample;

import com.greyu.ysj.mapper.CbtDrawMapper;
import com.greyu.ysj.mapper.InvTreeDAO;
import com.greyu.ysj.model.ResultModel;
import com.greyu.ysj.service.InvTreeService;

@Service
public class InvTreeServiceImpl implements InvTreeService {

	@Autowired
	private InvTreeDAO invTreeMapper;
	@Override
	public ResultModel save(InvTree invTree) {
		this.invTreeMapper.insert(invTree);
		return ResultModel.ok(invTree);
	}
	
	@Override
	public List<InvTree> selectAll(InvTree invTree) {
		InvTreeExample invTreeExample = new InvTreeExample();
		InvTreeExample.Criteria criteria = invTreeExample.createCriteria();
		criteria.andUserIdEqualTo(invTree.getUserId());
        List<InvTree> list = this.invTreeMapper.selectByExample(invTreeExample);
        return list;
	}
	
	 @Override
	    public ResultModel updateInvTreebyUserId( InvTree invTree) {
		 
		 	this.invTreeMapper.updateInvTreebyUserId(invTree);
	       
	        return ResultModel.ok(invTree);
	    }

	@Override
	public InvTree selectInvTreebyUserId(Integer userId) {
		InvTree invTree = this.invTreeMapper.selectInvTreebyUserId(userId);
		return invTree;
	}

}
